function  [h1, h2] = plot_results( results, par )
% This function plots the two dimensional solution p(w, lambda) with two figures; 
w_grid = par.w_grid;   lambda_grid = par.lambda_grid;
linewidth=1.5;  

% Output Figure 1 along the w dimension.
h1 = figure('position', [0, 0, 600, 500]);
j1= par.N_lambda-1 ; j2 = par.N_lambda-3 ;    % index of  lambdas chosen
w_index  = w_grid  > 0.01 ;   
w_subgrid = w_grid(w_index);
subplot(2,2,1);  plot(  w_subgrid, results.p_matrix(w_index,j1), '--' ,  w_subgrid,  results.p_matrix(w_index,j2),  ':'  ,  w_subgrid , par.p_ode45(w_index) , 'linewidth', linewidth  );    title('price $p$','interpreter','latex' );    xlabel('$w$','interpreter','latex');  legend(  {['$\lambda=$', num2str(lambda_grid(j1),1)] ,   ['$\lambda=$', num2str(lambda_grid(j2),1)], 'No bank run'} ,'interpreter','latex' );
subplot(2,2,2);  plot(  w_subgrid, results.kappap_matrix(w_index,j1), '--' ,  w_subgrid, results.kappap_matrix(w_index,j2),  ':'  ,  w_subgrid , 0*par.p_ode45(w_index) ,   'linewidth', linewidth  );    title('jump $\kappa^p$','interpreter','latex');    xlabel('$w$','interpreter','latex');  legend( {  ['$\lambda=$', num2str(lambda_grid(j1),1)] ,   ['$\lambda=$', num2str(lambda_grid(j2),1)], 'No bank run' },'interpreter','latex' );
subplot(2,2,3);  plot(  w_subgrid, results.xK_matrix(w_index,j1), '--' ,  w_subgrid, results.xK_matrix(w_index,j2),  ':'  ,  w_subgrid , par.xK_ode45(w_index) ,   'linewidth', linewidth  );    title('$x^K$','interpreter','latex');    xlabel('$w$','interpreter','latex');  legend(   {['$\lambda=$', num2str(lambda_grid(j1),1)] ,   ['$\lambda=$', num2str(lambda_grid(j2),1)], 'No bank run'}  ,'interpreter','latex');
subplot(2,2,4);  plot(  w_subgrid, results.credit_spread_matrix(w_index,j1), '--' ,  w_subgrid, results.credit_spread_matrix(w_index,j2),  ':'  ,  w_subgrid , par.CS_ode45(w_index) ,   'linewidth', linewidth  );    title('credit spread','interpreter','latex');    xlabel('$w$','interpreter','latex');  legend(  {['$\lambda=$', num2str(lambda_grid(j1),1)] ,   ['$\lambda=$', num2str(lambda_grid(j2),1)], 'No bank run' } ,'interpreter','latex');

% Output Figure 2
h2 = figure('position', [0, 0, 600, 500]);
[~,i1] = min( abs(w_grid-0.05) ) ;      [~,i2] = min( abs(w_grid-0.2) ) ;   % Index of w_grid that picks w closest to 0.1 and 0.5 
subplot(2,2,1);  plot(  lambda_grid, results.p_matrix(i1,:) ,  '--' , lambda_grid, results.p_matrix(i2,:) , ':' ,  0, par.p_ode45(i1), 'bo',  0, par.p_ode45(i2), 'r*',  'linewidth', linewidth  );    title('price $p$','interpreter','latex' );    xlabel('$\lambda$','interpreter','latex');  legend( { ['$w=$', num2str(w_grid(i1),1)] ,   ['$w=$', num2str(w_grid(i2),1)]}  ,'interpreter','latex');
subplot(2,2,2);  plot(  lambda_grid, results.kappap_matrix(i1,:) ,  '--' , lambda_grid, results.kappap_matrix(i2,:) , ':' ,  0, 0, 'bo',  0, 0, 'r*',  'linewidth', linewidth  );               title('jump $\kappa^p$','interpreter','latex');    xlabel('$\lambda$','interpreter','latex');   legend( { ['$w=$', num2str(w_grid(i1),1)] ,   ['$w=$', num2str(w_grid(i2),1)]}  ,'interpreter','latex');
subplot(2,2,3);  plot(  lambda_grid, results.xK_matrix(i1,:) ,  '--' , lambda_grid, results.xK_matrix(i2,:) , ':' ,  0, par.xK_ode45(i1), 'bo',  0, par.xK_ode45(i2), 'r*',  'linewidth', linewidth  );   title('$x^K$','interpreter','latex');     xlabel('$\lambda$','interpreter','latex');   legend( { ['$w=$', num2str(w_grid(i1),1)] ,   ['$w=$', num2str(w_grid(i2),1)]}  ,'interpreter','latex');
subplot(2,2,4);  plot(  lambda_grid, results.credit_spread_matrix(i1,:) ,  '--' , lambda_grid, results.credit_spread_matrix(i2,:) , ':' ,  0, par.CS_ode45(i1), 'bo',  0, par.CS_ode45(i2), 'r*',  'linewidth', linewidth  );   title('credit spread','interpreter','latex');      xlabel('$\lambda$','interpreter','latex');   legend( { ['$w=$', num2str(w_grid(i1),1)] ,   ['$w=$', num2str(w_grid(i2),1)]}  ,'interpreter','latex');




